AddStategraphPostInit("wilson", function(self)
	local doattack = self.events["doattack"]
	local old_fn = doattack.fn
	doattack.fn = function(inst, data)
		if IsModeRG() then
			-- [[RG]]
			if inst.components.health:IsDead() or inst.sg:HasStateTag("attack") then
				return nil
			end
			
            local weapon = inst.components.combat and inst.components.combat:GetWeapon()
            if weapon == nil then
            	inst.sg:GoToState("attack")
            	return
            end
            if weapon.attackstate ~= nil then
            	inst.sg:GoToState(weapon.attackstate)
            end

            if weapon:HasTag("goggles") then 
                inst.sg:GoToState("goggleattack")                
            elseif weapon:HasTag("blowdart") then
                inst.sg:GoToState("blowdart")
            elseif weapon:HasTag("thrown") then
                inst.sg:GoToState("throw")
            elseif weapon:HasTag("speargun") then 
                inst.sg:GoToState("speargun")
            elseif weapon:HasTag("blunderbuss") then 
                inst.sg:GoToState("speargun")
            else
                inst.sg:GoToState("attack")
            end

            return
		else
			return old_fn(inst, data)
		end
	end
end)

RG_AddComponentPostInit("combat", function(self)
    self.inst:AddComponent("rg_debuff")

    self.rg_debuff = self.inst.components.rg_debuff


    local old_attacked = self.GetAttacked
    function self:GetAttacked(attacker, damage, weapon, ...)
        if damage > 0 then
            -- 重伤
            damage = damage * 1
        end
        return old_attacked(self, attacker, damage, weapon, ...)
    end
end)

RG_AddSimPostInit(function(player)
    -- player has been spawn, so we should set it manually.


end)

	